// 设置本地存储
export const setLocal = (key: string, value: any) => {
    localStorage.setItem(key, JSON.stringify(value))
}
// 获取本地存储
export const getLocal = (key: string) => {
    try {
        const item = localStorage.getItem(key)
        if (!item) return null
        return JSON.parse(item)
    } catch (error) {
        console.error(`解析localStorage中的${key}失败:`, error)
        // 如果解析失败，尝试直接返回原始值
        return localStorage.getItem(key)
    }
}
// 删除本地存储
export const removeLocal = (key: string) => {
    localStorage.removeItem(key)
}
// 清空本地存储
export const clearLocal = () => {
    localStorage.clear()
}